package com.gitee.jmliu1983.finacehelper.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
//import com.ruoyi.common.log.annotation.Log;
//import com.ruoyi.common.log.enums.BusinessType;
//import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.gitee.jmliu1983.finacehelper.domain.TransactionsFund;
import com.gitee.jmliu1983.finacehelper.domain.TransactionsUsdRmb;
import com.gitee.jmliu1983.finacehelper.service.ITransactionsFundService;
import com.gitee.jmliu1983.finacehelper.service.ITransactionsUsdRmbService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
//import com.ruoyi.common.core.web.controller.BaseController;
//import com.ruoyi.common.core.web.domain.AjaxResult;
//import com.ruoyi.common.core.utils.poi.ExcelUtil;
//import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 美元理财Controller
 * 
 * @author ruoyi
 * @date 2025-03-06
 */
@RestController
@RequestMapping("/usd_rmb")
@PreAuthorize("@ss.hasRole('finace')")
public class TransactionsUsdRmbController extends BaseController
{
    @Autowired
    private ITransactionsUsdRmbService transactionsUsdRmbService;

    /**
     * 查询美元理财列表
     */
//    @RequiresPermissions("finace:usd_rmb:list")
    @GetMapping("/list")
    public TableDataInfo list(TransactionsUsdRmb transactionsUsdRmb)
    {
        startPage();
        List<TransactionsUsdRmb> list = transactionsUsdRmbService.selectTransactionsUsdRmbList(transactionsUsdRmb);
        return getDataTable(list);
    }

    /**
     * 导出美元理财列表
     */
//    @RequiresPermissions("finace:usd_rmb:export")
    @Log(title = "美元理财", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TransactionsUsdRmb transactionsUsdRmb)
    {
        List<TransactionsUsdRmb> list = transactionsUsdRmbService.selectTransactionsUsdRmbList(transactionsUsdRmb);
        ExcelUtil<TransactionsUsdRmb> util = new ExcelUtil<TransactionsUsdRmb>(TransactionsUsdRmb.class);
        util.exportExcel(response, list, "美元理财数据");
    }

    /**
     * 获取美元理财详细信息
     */
//    @RequiresPermissions("finace:usd_rmb:query")
    @GetMapping(value = "/{transactionId}")
    public AjaxResult getInfo(@PathVariable("transactionId") Long transactionId)
    {
        return success(transactionsUsdRmbService.selectTransactionsUsdRmbByTransactionId(transactionId));
    }

    /**
     * 新增美元理财
     */
//    @RequiresPermissions("finace:usd_rmb:add")
    @Log(title = "美元理财", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TransactionsUsdRmb transactionsUsdRmb)
    {
        return toAjax(transactionsUsdRmbService.insertTransactionsUsdRmb(transactionsUsdRmb));
    }

    /**
     * 修改美元理财
     */
//    @RequiresPermissions("finace:usd_rmb:edit")
    @Log(title = "美元理财", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TransactionsUsdRmb transactionsUsdRmb)
    {
        return toAjax(transactionsUsdRmbService.updateTransactionsUsdRmb(transactionsUsdRmb));
    }

    /**
     * 删除美元理财
     */
//    @RequiresPermissions("finace:usd_rmb:remove")
    @Log(title = "美元理财", businessType = BusinessType.DELETE)
	@DeleteMapping("/{transactionIds}")
    public AjaxResult remove(@PathVariable Long[] transactionIds)
    {
        return toAjax(transactionsUsdRmbService.deleteTransactionsUsdRmbByTransactionIds(transactionIds));
    }
}
